<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>reduce</title>
</head>
<body>
<script>
    var numbers = [1, 2, 3, 4, 5];
    const average = numbers.reduce(((previousValue, currentValue, currentIndex, array) => {
        return currentIndex === array.length - 1 ? (previousValue + currentValue) / array.length : previousValue + currentValue
    }), 0);
    console.log(average)

    var str = "Samuel";
    console.log(Array.prototype.reverse.call(str.split('')).join(''));
</script>
</body>
</html>
